import Dialog from '../../../dist/dialog/dialog';
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    info: {},
    id: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.id) {
      this.setData({
        id: options.id
      })
      this.getData({
        id: options.id
      })
    }
  },
  showOneImage(evt){
    let src = evt.currentTarget.dataset.src;
    wx.previewImage({
      urls:[src]
    });
  },
  showAllImage(evt){
    let src = evt.currentTarget.dataset.src;
    wx.previewImage({
      urls:src
    });
  },
  apply_handle(e) {
    let id = this.data.id;
    let type = e.currentTarget.dataset.type;
    let message = '';
    if (type == 'pass') {
      message = "是否确认通过该门店申请？"
    } else {
      message = "是否确认驳回该门店申请？"
    }
    Dialog.confirm({
      message,
    }).then(() => {
      let urlStr = '';
      if (type == 'pass') {
        urlStr = 'plugin.store-cashier.frontend.store.parent-apply.accept';
      } else {
        urlStr = 'plugin.store-cashier.frontend.store.parent-apply.reject';
      }
      app._getNetWork({
        url:app.getNetAddresss(urlStr),
        data:{id},
        success:resdata=>{
          let {result,msg} = resdata.data;
          app.tips(msg);
          if(result == 1){
            wx.navigateTo({
              url: '/packageI/store_audit/list/list',
            })
          }
        }
      })
    })
      .catch(() => {
        // on cancel
      });
  },
  getData(json) {
    app._postNetWork({
      url: app.getNetAddresss('plugin.store-cashier.frontend.store.parent-apply.detail'),
      data: json,
      success: resdata => {
        let {
          result,
          msg,
          data
        } = resdata.data;
        if (result == 0) {
          return app.tips(msg);
        }
        this.setData({
          info: data
        });
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})